﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<ComputerTargetGroupViewModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Computer group -
    <%=Model.Group.Name %>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2>
        Computer group -
        <%=Model.Group.Name%></h2>
    <p>
        <%if (Model.ParentGroup != null)
          {%>
        Parent group:
        <%=Html.RouteLink().ComputerTargetGroupDetails(Model.ParentGroup.Name,Model.ParentGroup.Id) %>
        <%} %>
    </p>
    <div id="updates" class="infoBox">
        <fieldset>
            <legend>Updates</legend>
            <p>
                Installed updates:
                <%=Model.UpdateSummary.InstalledCount %>
            </p>
            <p>
                Installed updates (reboot pending):
                <%=Model.UpdateSummary.InstalledPendingRebootCount %>
            </p>
            <p>
                Not installed updates:
                <%=Model.UpdateSummary.NotInstalledCount %>
            </p>
            <p>
                Failed updates:
                <%=Model.UpdateSummary.FailedCount %>
            </p>
            <p>
                Not applicable:
                <%=Model.UpdateSummary.NotApplicableCount %>
            </p>
        </fieldset>
    </div>
    <div id="childGroups" class="infoBox">
        <fieldset>
            <legend>Child groups</legend>
            <ul>
                <%foreach (IComputerTargetGroup item in Model.ChildGroups)
                  {%>
                <li>
                    <%=Html.RouteLink().ComputerTargetGroupDetails(item.Name,item.Id) %></li>
                <%} %>
            </ul>
            </fieldset>
    </div>
    
    <%Html.Telerik().Grid<IComputerTarget>()
                    .Name("computerTargets")
                    .Sortable()
                    .Pageable(pager=>pager.PageSize(10).Position(GridPagerPosition.Bottom).Style(GridPagerStyles.NextPreviousAndInput))
                    .Columns(columns =>
                         {
                             columns.Add(x => x.Id);
                             columns.Add(x => x.FullDomainName).Title("Computer name");
                             columns.Add(x => x.LastReportedStatusTime).Title("Last reported status");
                         })
                    .Ajax(ajax => ajax.Route(Routes.ComputerTargetsInGroupRoute, new { Id = Model.Group.Id }))
                    .Render();%>

<div id="computerTargetDetails">
</div>

</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="HeadContent" runat="server">
<link rel="Stylesheet" type="text/css" href="/Content/ComputerTargetGroup/Details.css" />
<script type="text/javascript">
    $(document).ready(function () {
        $('#computerTargets tbody tr')
                .live("click", function () {
                    // `this` == clicked row

                    var targetId = this.cells[0].innerHTML;

                    // add selected style to clicked row
                    $(this).addClass('t-state-selected')
                           .siblings()
                           .removeClass('t-state-selected');

                    $("#computerTargetDetails")                        
                        .addClass("loading")
                        .html("")
                        .load('/Computer/' + targetId + '/Details', {}, function () {
                            $("#computerTargetDetails").removeClass("loading");
                        });
                })
                .live("mouseenter", $.telerik.hover) /* add hover effects */
                .live("mouseleave", $.telerik.leave);
    });
</script>
</asp:Content>
